﻿#region copyright
//<copyright>
// Copyright(C) 2012 TrackerRealm Corporation
// This file is part of the open source project - Jazz. http://jazz.codeplex.com
// 
// Jazz is open software: you can redistribute it and/or modify it 
// under the terms of the GNU Affero General Public License (AGPL) as published by 
// the Free Software Foundation, version 3 of the License.
// 
// Jazz is distributed in the hope that it will be useful, 
// but WITHOUT ANY WARRANTY; without even the implied warranty 
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
//  See the GNU Affero General Public License (AGPL) for more details.
// 
// You should have received a copy of the GNU General Public 
// License along with Jazz.  If not, see <http://www.gnu.org/licenses/>.
//
// REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT. 
//</copyright>
#endregion
using System;
using System.Text;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TrackerRealm.Jazz.Client;
using PostSharp.Extensibility;
using KellermanSoftware.CompareNetObjects;
using TrackerRealm.Jazz.Common;

namespace JazzClientTest
{
    /// <summary>
    /// 
    /// </summary>
    public static class ToolExtensionMethods
    {
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="objects"></param>
        /// <param name="compareTo"></param>
        /// <returns></returns>
        public static IEnumerable<string> DeepCompare<T>(this IEnumerable<T> objects, IEnumerable<T> compareTo)
        {
            CompareObjects co = new CompareObjects();
            co.CompareProperties = false; // don't bother comparing properties - need to ignore more - lazy
            co.ComparePrivateFields = true;
            List<string> ignoreList = new List<string>();
            ignoreList.Add(Constants_JazzObjectFields.CLIENTNEXUS);
            ignoreList.Add(Constants_JazzObjectFields.JAZZCLASS);
            ignoreList.Add("methodInfo");  // bug in CompareObjects - it doesn't like comparing MethodInfo objects
            co.ElementsToIgnore = ignoreList;
            co.Compare(objects, compareTo);
            return co.Differences;
        }
    }
}
